#include "Cursor_selection.h"
#include "Close_System.h"
#include "test.h"


extern StateMachine sm;


void KEY_MENU_CHOOSE(void)
{
	LCD_Clear_Triangel(WHITE);
	Triangel_draw_state(sm.current_state);
}


void LCD_Clear_Triangel(uint16_t Color)
{
    unsigned int i;//,m;
    uint32_t total_point=57*15;

    LCD_SetWindows(FIRST_COLUMN_X-20,FIRST_ROW_Y+58-53,FIRST_COLUMN_X-20+15,FIRST_ROW_Y+58-49+53);
    for(i=0;i<total_point;i++)
    {
        LCD->LCD_RAM = Color;
    }

    LCD_SetWindows(SECOND_COLUMN_X-20,FIRST_ROW_Y+58-53,SECOND_COLUMN_X-20+15,FIRST_ROW_Y+58-49+53);
    for(i=0;i<total_point;i++)
    {
        LCD->LCD_RAM = Color;
    }

    LCD_SetWindows(SECOND_COLUMN_X-20,SECOND_ROW_Y+58-53,SECOND_COLUMN_X-20+15,SECOND_ROW_Y+58-49+53);
    for(i=0;i<total_point;i++)
    {
        LCD->LCD_RAM = Color;
    }

    LCD_SetWindows(FIRST_COLUMN_X-20,SECOND_ROW_Y+58-53,FIRST_COLUMN_X-20+15,SECOND_ROW_Y+58-49+53);
    for(i=0;i<total_point;i++)
    {
        LCD->LCD_RAM = Color;
    }
}

void Triangel_draw_state(State current_state_)
{
    switch(current_state_)
    {
        case MENU_1:
            Triangel_fill(FIRST_COLUMN_X-20,FIRST_ROW_Y+58);
            break;
        case MENU_2:
            Triangel_fill(SECOND_COLUMN_X-20,FIRST_ROW_Y+58);
            break;
        case MENU_4:
            Triangel_fill(SECOND_COLUMN_X-20,SECOND_ROW_Y+58);
            break;
        case MENU_3:
            Triangel_fill(FIRST_COLUMN_X-20,SECOND_ROW_Y+58);
            break;
        default:
            Triangel_fill(FIRST_COLUMN_X-20,FIRST_ROW_Y+58);
            break;
    }
}

void Triangel_fill(uint16_t triangel_x,uint16_t triangel_y)
{
    POINT_COLOR=RED;
    Fill_Triangel(triangel_x,      triangel_y,
                  triangel_x,      triangel_y-53,
                  triangel_x + 15, triangel_y-26);
}

